
<!DOCTYPE HTML>
<html lang="" >
    <head>
        <meta charset="UTF-8">
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <title>GPIO外设实现流水灯 · WQ GitBook</title>
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="description" content="">
        <meta name="generator" content="GitBook 3.2.3">
        
        
        
    
    <link rel="stylesheet" href="../gitbook/style.css">

    
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-intopic-toc/style.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-callouts/plugin.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-page-footer-ex/style/plugin.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-highlight/website.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-search/search.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-fontsettings/website.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-theme-comscore/test.css">
                
            
        

    

    
        
        <link rel="stylesheet" href="../styles/styles.css">
        
    

        
    
    
    <meta name="HandheldFriendly" content="true"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="apple-touch-icon-precomposed" sizes="152x152" href="../gitbook/images/apple-touch-icon-precomposed-152.png">
    <link rel="shortcut icon" href="../gitbook/images/favicon.ico" type="image/x-icon">

    
    <link rel="next" href="WaterLight.html" />
    
    
    <link rel="prev" href="data_storage.html" />
    

    </head>
    <body>
        
<div class="book">
    <div class="book-summary">
        
            
<div id="book-search-input" role="search">
    <input type="text" placeholder="Type to search" />
</div>

            
                <nav role="navigation">
                


<ul class="summary">
    
    

    

    
        
        
    
        <li class="chapter " data-level="1.1" data-path="../">
            
                <a href="../">
            
                    
                    Introduction
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2" data-path="../lab0/introduction.html">
            
                <a href="../lab0/introduction.html">
            
                    
                    LAB0: 工欲善其事 必先利其器
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.2.1" data-path="../lab0/FPGAintro.html">
            
                <a href="../lab0/FPGAintro.html">
            
                    
                    FPGA 简介
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.2" data-path="../lab0/whyFPGA.html">
            
                <a href="../lab0/whyFPGA.html">
            
                    
                    为什么是 FPGA？
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.3" data-path="../lab0/design_method.html">
            
                <a href="../lab0/design_method.html">
            
                    
                    设计方法
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.4" data-path="../lab0/board_intro.html">
            
                <a href="../lab0/board_intro.html">
            
                    
                    平台介绍
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.5" data-path="../lab0/intro_tools.html">
            
                <a href="../lab0/intro_tools.html">
            
                    
                    软硬件关系
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.6" data-path="../lab0/keil.html">
            
                <a href="../lab0/keil.html">
            
                    
                    Keil
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.7" data-path="../lab0/vivado.html">
            
                <a href="../lab0/vivado.html">
            
                    
                    Vivado
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.8" data-path="../lab0/modelsim.html">
            
                <a href="../lab0/modelsim.html">
            
                    
                    Modelsim
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.3" data-path="../lab1/introduction.html">
            
                <a href="../lab1/introduction.html">
            
                    
                    LAB1: "施法"让 CPU 动起来
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.3.1" data-path="../lab1/sec_1.html">
            
                <a href="../lab1/sec_1.html">
            
                    
                    ARM 汇编回顾
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.2" data-path="../lab1/sec_2.html">
            
                <a href="../lab1/sec_2.html">
            
                    
                    搭建 Keil 环境
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.3" data-path="../lab1/sec_3.html">
            
                <a href="../lab1/sec_3.html">
            
                    
                    运行吧, 第一个汇编程序
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.4" data-path="../lab1/sec_5.html">
            
                <a href="../lab1/sec_5.html">
            
                    
                    栈 - 函数调用的指挥官
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.5" data-path="../lab1/sec_6.html">
            
                <a href="../lab1/sec_6.html">
            
                    
                    自己动手, 理解函数调用
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.4" data-path="../lab2/introduction.html">
            
                <a href="../lab2/introduction.html">
            
                    
                    LAB2: "点石成金" - 实现你的首个 SoC
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.4.1" data-path="../lab2/sec_1.html">
            
                <a href="../lab2/sec_1.html">
            
                    
                    硬件部分说明
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.2" data-path="../lab2/sec_2.html">
            
                <a href="../lab2/sec_2.html">
            
                    
                    搭建 Keil 工程
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.3" data-path="../lab2/sec_3.html">
            
                <a href="../lab2/sec_3.html">
            
                    
                    Modelsim 仿真
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.4" data-path="../lab2/sec_4.html">
            
                <a href="../lab2/sec_4.html">
            
                    
                    下载比特流到 FPGA
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.5" data-path="../lab2/sec_5.html">
            
                <a href="../lab2/sec_5.html">
            
                    
                    将硬件固化到开发板
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.6" data-path="../lab2/sec_6.html">
            
                <a href="../lab2/sec_6.html">
            
                    
                    使用 Keil 调试
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.5" data-path="introduction.html">
            
                <a href="introduction.html">
            
                    
                    LAB3: "灯, 等灯, 等灯"-流水灯的几种点法
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.5.1" data-path="data_storage.html">
            
                <a href="data_storage.html">
            
                    
                    数据存储器
            
                </a>
            

            
        </li>
    
        <li class="chapter active" data-level="1.5.2" data-path="GPIO.html">
            
                <a href="GPIO.html">
            
                    
                    GPIO外设实现流水灯
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.3" data-path="WaterLight.html">
            
                <a href="WaterLight.html">
            
                    
                    硬件流水灯
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.6" data-path="../lab4/introduction.html">
            
                <a href="../lab4/introduction.html">
            
                    
                    LAB4: 如何召唤"沉睡的软件"
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.6.1" data-path="../lab4/keyboards.html">
            
                <a href="../lab4/keyboards.html">
            
                    
                    矩阵键盘原理
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.2" data-path="../lab4/keyboards_waterlight.html">
            
                <a href="../lab4/keyboards_waterlight.html">
            
                    
                    使用矩阵键盘4个按键控制流水灯模式
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.3" data-path="../lab4/keyboards_led.html">
            
                <a href="../lab4/keyboards_led.html">
            
                    
                    使用矩阵键盘控制数码管显示
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.7" data-path="../verilog/introduction.html">
            
                <a href="../verilog/introduction.html">
            
                    
                    附录
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.7.1" data-path="../verilog/grammar.html">
            
                <a href="../verilog/grammar.html">
            
                    
                    Verilog基本语法
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.2" data-path="../verilog/enable_signal.html">
            
                <a href="../verilog/enable_signal.html">
            
                    
                    使能信号
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.3" data-path="../verilog/decoder.html">
            
                <a href="../verilog/decoder.html">
            
                    
                    总线译码器
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.8" data-path="../faq/introduction.html">
            
                <a href="../faq/introduction.html">
            
                    
                    常见问题
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.9" data-path="../add_notice.html">
            
                <a href="../add_notice.html">
            
                    
                    补充通知
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.10" data-path="../about/introduction.html">
            
                <a href="../about/introduction.html">
            
                    
                    About
            
                </a>
            

            
        </li>
    

    

    <li class="divider"></li>

    <li>
        <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
            Published with GitBook
        </a>
    </li>
</ul>


                </nav>
            
        
    </div>

    <div class="book-body">
        
            <div class="body-inner">
                
                    

<div class="book-header" role="navigation">
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href=".." >GPIO外设实现流水灯</a>
    </h1>
</div>




                    <div class="page-wrapper" tabindex="-1" role="main">
                        <div class="page-inner">
                            
<div id="book-search-results">
    <div class="search-noresults">
    
                                <section class="normal markdown-section">
                                
                                <h1 id="gpio&#x5916;&#x8BBE;&#x5B9E;&#x73B0;&#x6D41;&#x6C34;&#x706F;">GPIO&#x5916;&#x8BBE;&#x5B9E;&#x73B0;&#x6D41;&#x6C34;&#x706F;</h1>
<p><div align="center"><img src="../img/lab3/09.png" alt="01" style="zoom:100%;"></div></p>
<center style="color:#000000;font-size:10pt;">&#x672C;&#x7AE0;&#x5B9E;&#x73B0;&#x7684;SoC</center>

<!-- -->
<div class="panel panel-success"><div class="panel-heading"><h5 class="panel-title" id="gpio&#x5916;&#x8BBE;&#x5B9E;&#x73B0;&#x6D41;&#x6C34;&#x706F;"><i class="fa fa-flag"></i> GPIO&#x5916;&#x8BBE;&#x5B9E;&#x73B0;&#x6D41;&#x6C34;&#x706F;</h5></div><div class="panel-body"><p>&#x63A5;&#x4E0B;&#x6765;, &#x5C06;&#x4ECB;&#x7ECD;&#x5982;&#x4F55;&#x5C06; GPIO &#x96C6;&#x6210;&#x5230; SoC &#x7CFB;&#x7EDF;&#x4E2D;, &#x5E76;&#x4E14;&#x4F7F;&#x7528;&#x8F6F;&#x4EF6;&#x7F16;&#x7A0B;&#x63A7;&#x5236;&#x5B83;&#x5B9E;&#x73B0;&#x6D41;&#x6C34;&#x706F;&#x7684;&#x529F;&#x80FD;.</p></div></div>
<h2 id="gpio-&#x4ECB;&#x7ECD;">GPIO &#x4ECB;&#x7ECD;</h2>
<p>&#x901A;&#x7528;&#x8F93;&#x5165;/&#x8F93;&#x51FA;&#x63A5;&#x53E3;(General-purpose input/output, GPIO), &#x662F;&#x4E00;&#x79CD;&#x5E38;&#x7528;&#x4E8E;&#x5904;&#x7406;&#x5668;&#x7CFB;&#x7EDF;&#x7684;&#x5916;&#x8BBE;&#x63A5;&#x53E3;, &#x5176;&#x7279;&#x70B9;&#x662F;&#x5177;&#x6709;&#x8F93;&#x51FA;/&#x8F93;&#x5165;&#x903B;&#x8F91;&#x7535;&#x5E73;&#x7684;&#x529F;&#x80FD;.</p>
<p>&#x901A;&#x4FD7;&#x5730;&#x8BF4;, &#x5C31;&#x662F;&#x4E00;&#x4E9B;&#x5F15;&#x811A;, &#x53EF;&#x4EE5;&#x901A;&#x8FC7;&#x5B83;&#x4EEC;&#x8F93;&#x51FA;&#x9AD8;&#x4F4E;&#x7535;&#x5E73;&#x6216;&#x8005;&#x901A;&#x8FC7;&#x5B83;&#x4EEC;&#x8BFB;&#x5165;&#x5F15;&#x811A;&#x7684;&#x72B6;&#x6001;&#x662F;&#x9AD8;&#x7535;&#x5E73;&#x6216;&#x662F;&#x4F4E;&#x7535;&#x5E73;. GPIO &#x662F;&#x4E2A;&#x6BD4;&#x8F83;&#x91CD;&#x8981;&#x7684;&#x6982;&#x5FF5;, &#x7528;&#x6237;&#x53EF;&#x4EE5;&#x901A;&#x8FC7; GPIO &#x53E3;&#x548C;&#x786C;&#x4EF6;&#x8FDB;&#x884C;&#x6570;&#x636E;&#x4EA4;&#x4E92; (&#x5982;UART), &#x63A7;&#x5236;&#x786C;&#x4EF6;&#x5DE5;&#x4F5C; (&#x5982;LED&#x3001;&#x8702;&#x9E23;&#x5668;&#x7B49;), &#x8BFB;&#x53D6;&#x786C;&#x4EF6;&#x7684;&#x5DE5;&#x4F5C;&#x72B6;&#x6001;&#x4FE1;&#x53F7; (&#x5982;&#x4E2D;&#x65AD;&#x4FE1;&#x53F7;) &#x7B49;. GPIO &#x53E3;&#x7684;&#x4F7F;&#x7528;&#x975E;&#x5E38;&#x5E7F;&#x6CDB;. &#x638C;&#x63E1;&#x4E86; GPIO, &#x5DEE;&#x4E0D;&#x591A;&#x76F8;&#x5F53;&#x4E8E;&#x638C;&#x63E1;&#x4E86;&#x64CD;&#x4F5C;&#x786C;&#x4EF6;&#x7684;&#x80FD;&#x529B;.</p>
<p>&#x8BBE;&#x8BA1; GPIO &#x5916;&#x8BBE;&#x7684;&#x76EE;&#x7684;&#x5C31;&#x662F;&#x4E3A;&#x4E86;&#x63D0;&#x9AD8; SoC &#x7CFB;&#x7EDF;&#x7684;&#x901A;&#x7528;&#x6027;. &#x4EE5;&#x5355;&#x7247;&#x673A;&#x8FD9;&#x4E00; SoC &#x7CFB;&#x7EDF;&#x4E3A;&#x4F8B;, &#x5355;&#x7247;&#x673A;&#x4F5C;&#x4E3A;&#x5DE5;&#x4E1A;&#x8BBE;&#x5907;&#x7684;&#x63A7;&#x5236;&#x6838;&#x5FC3;, &#x5F80;&#x5F80;&#x9700;&#x8981;&#x9A71;&#x52A8;&#x4E0D;&#x540C;&#x7684;&#x82AF;&#x7247;, &#x8FD9;&#x4E9B;&#x82AF;&#x7247;&#x7684;&#x901A;&#x4FE1;&#x534F;&#x8BAE;&#x5404;&#x4E0D;&#x76F8;&#x540C;, SoC &#x8BBE;&#x8BA1;&#x4EBA;&#x5458;&#x4E0D;&#x53EF;&#x80FD;&#x628A;&#x6BCF;&#x4E00;&#x79CD;&#x82AF;&#x7247;&#x7684;&#x901A;&#x4FE1;&#x534F;&#x8BAE;&#x90FD;&#x5236;&#x4F5C;&#x6210;&#x786C;&#x4EF6;&#x7684;&#x5F62;&#x5F0F;&#x96C6;&#x6210;&#x5728; SoC &#x4E2D;. &#x56E0;&#x6B64;, &#x8BBE;&#x8BA1; GPIO &#x5916;&#x8BBE;, &#x8BA9;&#x7F16;&#x7A0B;&#x4EBA;&#x5458;&#x901A;&#x8FC7;&#x5904;&#x7406;&#x5668;&#x63A7;&#x5236; GPIO &#x63A5;&#x53E3;&#x6A21;&#x62DF;&#x5404;&#x4E2A;&#x9A71;&#x52A8;&#x82AF;&#x7247;&#x7684;&#x901A;&#x4FE1;&#x65F6;&#x5E8F;&#x4EE5;&#x8FBE;&#x5230;&#x9A71;&#x52A8;&#x5404;&#x4E2A;&#x5916;&#x90E8;&#x82AF;&#x7247;&#x7684;&#x529F;&#x80FD;. GPIO &#x63A5;&#x53E3;&#x80FD;&#x591F;&#x907F;&#x514D;&#x6CA1;&#x6709;&#x7279;&#x6B8A;&#x82AF;&#x7247;&#x7684;&#x901A;&#x4FE1;&#x65F6;&#x5E8F;&#x7684;&#x5C34;&#x5C2C;.</p>
<p>&#x5982;&#x679C;&#x719F;&#x6089;&#x5355;&#x7247;&#x673A;&#x7684;&#x540C;&#x5B66;, &#x5C31;&#x4F1A;&#x77E5;&#x9053;, &#x51E0;&#x4E4E;&#x6240;&#x6709;&#x7684;&#x5355;&#x7247;&#x673A;&#x90FD;&#x5177;&#x6709; GPIO &#x63A5;&#x53E3;. &#x5728;&#x4E00;&#x4E9B;&#x5355;&#x7247;&#x673A;&#x4E2D;, GPIO &#x63A5;&#x53E3;&#x8FD8;&#x53EF;&#x4EE5;&#x914D;&#x7F6E;&#x8FDE;&#x63A5;&#x5230;&#x5904;&#x7406;&#x5668;&#x7684; IRQ &#x4E2D;&#x65AD;&#x4E0A;, &#x5141;&#x8BB8; SoC &#x7CFB;&#x7EDF;&#x5916;&#x7684;&#x7535;&#x5E73;&#x4FE1;&#x53F7;&#x89E6;&#x53D1;&#x4E2D;&#x65AD;.&#x5728;&#x5E02;&#x573A;&#x4E0A;&#x5546;&#x7528;&#x7684;&#x5355;&#x7247;&#x673A;&#x4E2D;, GPIO &#x5F80;&#x5F80;&#x5177;&#x6709;&#x51E0;&#x79CD;&#x4E0D;&#x540C;&#x8F93;&#x5165;/&#x8F93;&#x51FA;&#x6A21;&#x5F0F;, &#x4EE5;&#x9002;&#x5E94;&#x4E0D;&#x540C;&#x7684;&#x5E94;&#x7528;&#x573A;&#x666F;. &#x8FD9;&#x51E0;&#x4E0D;&#x540C;&#x7684;&#x6A21;&#x5F0F;, &#x5927;&#x81F4;&#x53EF;&#x4EE5;&#x5206;&#x4E3A;: &#x6D6E;&#x7A7A;&#x8F93;&#x5165;&#x3001;&#x4E0A;&#x62C9;&#x8F93;&#x5165;&#x3001;&#x4E0B;&#x62C9;&#x8F93;&#x5165;&#x3001;&#x6A21;&#x62DF;&#x8F93;&#x5165;&#x3001;&#x5F00;&#x6F0F;&#x8F93;&#x51FA;&#x3001;&#x63A8;&#x633D;&#x8F93;&#x51FA;&#x548C;&#x4E00;&#x4E9B;&#x590D;&#x7528;&#x529F;&#x80FD;&#x7684;&#x8F93;&#x5165;/&#x8F93;&#x51FA;&#x6A21;&#x5F0F;. &#x4E0B;&#x9762;&#x5206;&#x522B;&#x4ECB;&#x7ECD;&#x4E00;&#x4E0B;&#x5B83;&#x4EEC;&#x7684;&#x7528;&#x9014;:</p>
<ul>
<li>&#x6D6E;&#x7A7A;&#x8F93;&#x5165;: &#x53EF;&#x4EE5;&#x7406;&#x89E3;&#x4E3A; GPIO &#x7AEF;&#x53E3;&#x65E2;&#x6CA1;&#x6709;&#x4E0A;&#x62C9;&#x7535;&#x963B;&#x4E5F;&#x6CA1;&#x6709;&#x4E0B;&#x62C9;&#x7535;&#x963B;, &#x5728;&#x65E0;&#x4FE1;&#x53F7;&#x8F93;&#x5165;&#x7684;&#x60C5;&#x51B5;&#x8F93;&#x5165;&#x72B6;&#x6001;&#x7684;&#x7535;&#x5E73;&#x662F;&#x4E0D;&#x786E;&#x5B9A;&#x7684;.</li>
<li>&#x4E0A;&#x62C9;&#x8F93;&#x5165;: &#x53EF;&#x4EE5;&#x7406;&#x89E3;&#x4E3A; GPIO &#x7AEF;&#x53E3;&#x62E5;&#x6709;&#x4E00;&#x4E2A;&#x4E0A;&#x62C9;&#x7535;&#x963B;&#x63A5;&#x5230; VDD , &#x5728;&#x65E0;&#x4FE1;&#x53F7;&#x8F93;&#x5165;&#x7684;&#x60C5;&#x51B5;&#x4E0B;&#x8F93;&#x5165;&#x72B6;&#x6001;&#x662F;&#x9AD8;&#x7535;&#x5E73;.</li>
<li>&#x4E0B;&#x62C9;&#x8F93;&#x5165;: &#x53EF;&#x4EE5;&#x7406;&#x89E3;&#x4E3A; GPIO &#x7AEF;&#x53E3;&#x62E5;&#x6709;&#x4E00;&#x4E2A;&#x4E0B;&#x62C9;&#x7535;&#x963B;&#x63A5;&#x5230; GND , &#x5728;&#x65E0;&#x4FE1;&#x53F7;&#x8F93;&#x5165;&#x7684;&#x60C5;&#x51B5;&#x4E0B;&#x8F93;&#x5165;&#x72B6;&#x6001;&#x662F;&#x4F4E;&#x7535;&#x5E73;.</li>
<li>&#x6A21;&#x62DF;&#x8F93;&#x5165;: &#x5C31;&#x662F;&#x4FE1;&#x53F7;&#x8F93;&#x5165;&#x7684;&#x8FC7;&#x7A0B;&#x4E2D;&#x4F1A;&#x7ECF;&#x8FC7;&#x653E;&#x5927;&#x5668;&#x3001;&#x7F13;&#x51B2;&#x5668;&#x7B49;&#x6A21;&#x62DF;&#x7535;&#x8DEF;, &#x901A;&#x5E38;&#x7528;&#x4E8E;&#x5185;&#x90E8;&#x96C6;&#x6210;&#x7684; ADC &#x8F93;&#x5165;&#x7AEF;&#x53E3;.</li>
<li>&#x5F00;&#x6F0F;&#x8F93;&#x51FA;: &#x53EF;&#x4EE5;&#x7406;&#x89E3;&#x4E3A;&#x4E09;&#x6781;&#x7BA1;&#x96C6;&#x6781;&#x8F93;&#x51FA;&#x7535;&#x8DEF;, &#x8981;&#x8F93;&#x51FA;&#x9AD8;&#x7535;&#x5E73;&#x9700;&#x8981;&#x5916;&#x63A5;&#x4E0A;&#x62C9;&#x7535;&#x963B;.</li>
<li>&#x63A8;&#x633D;&#x8F93;&#x51FA;: &#x8F93;&#x51FA;&#x7AEF;&#x4E24;&#x4E2A;&#x4E92;&#x8865; MOS &#x7BA1;&#x6784;&#x6210;&#x63A8;&#x633D;&#x7ED3;&#x6784;&#x8F93;&#x51FA;, &#x5176;&#x7279;&#x70B9;&#x662F;&#x65E2;&#x53EF;&#x4EE5;&#x8F93;&#x5165;&#x7535;&#x6D41;&#x4E5F;&#x53EF;&#x4EE5;&#x8F93;&#x51FA;&#x7535;&#x6D41;.</li>
</ul>
<p>&#x8981;&#x5B9E;&#x73B0;&#x8FD9;&#x4E9B;&#x4E0D;&#x540C;&#x72B6;&#x6001;&#x7684;&#x5207;&#x6362;, &#x9700;&#x8981;&#x5728;&#x8BBE;&#x8BA1;&#x82AF;&#x7247;&#x7684;&#x65F6;&#x5019;&#x8BBE;&#x8BA1;&#x4E86;&#x4E0D;&#x540C;&#x7684;&#x6A21;&#x62DF;&#x7535;&#x8DEF;&#x8FDB;&#x884C;&#x914D;&#x5408;. &#x5728;&#x505A;&#x6570;&#x5B57;&#x8BBE;&#x8BA1;&#x65F6;, &#x6211;&#x4EEC;&#x4E0D;&#x80FD;&#x5B9E;&#x73B0;&#x4E0A;&#x8FF0;&#x7684;&#x90A3;&#x4E9B;&#x6A21;&#x62DF;&#x7535;&#x8DEF;, &#x80FD;&#x591F;&#x5B9E;&#x73B0;&#x7684;&#x662F;&#x4E00;&#x4E9B;&#x9009;&#x62E9;&#x4E0D;&#x540C;&#x8F93;&#x51FA;&#x6A21;&#x5F0F;&#x5F00;&#x5173;&#x63A7;&#x5236;&#x4FE1;&#x53F7;&#x548C;&#x5982;&#x4E0B;&#x56FE;&#x6240;&#x793A;&#x7684; GPIO &#x6A21;&#x5757;.</p>
<p><div align="center"><img src="../img/lab3/10.png" alt="01" style="zoom:100%;"></div></p>
<center style="color:#000000;font-size:10pt;">GPIO&#x6A21;&#x5757;</center>

<p>&#x672C;&#x6B21;&#x5B9E;&#x9A8C;&#x5B9E;&#x73B0;&#x7684; GPIO &#x5916;&#x8BBE;&#x5C31;&#x5982;&#x4E0A;&#x56FE;&#x6240;&#x793A;. &#x8BF4;&#x5230;&#x8FD9;&#x91CC;, &#x6211;&#x4EEC;&#x5148;&#x4ECB;&#x7ECD;&#x5904;&#x7406;&#x5668;&#x6838;&#x5FC3;&#x662F;&#x5982;&#x4F55;&#x8BA9;&#x8FD9;&#x4E9B;&#x5916;&#x8BBE;&#x6309;&#x7167;&#x60F3;&#x8981;&#x7684;&#x65B9;&#x5F0F;&#x5DE5;&#x4F5C;. &#x8FD9;&#x91CC;&#x5C31;&#x6D89;&#x53CA;&#x5230;&#x4E86;<strong>&#x63A7;&#x5236;&#x5B57;</strong>&#x7684;&#x6982;&#x5FF5;, &#x5728;&#x4E4B;&#x524D;&#x7684;&#x5185;&#x5BB9;&#x4E2D;, &#x6211;&#x4EEC;&#x4ECB;&#x7ECD;&#x4E86;&#x5904;&#x7406;&#x5668;&#x901A;&#x8FC7;&#x603B;&#x7EBF;&#x7ED9;&#x56FA;&#x5B9A;&#x7684;&#x5730;&#x5740;&#x5199;&#x5165;&#x4E00;&#x4E2A;&#x5B57;&#x957F;&#x6570;&#x636E;, &#x8FD9;&#x4E2A;&#x7528;&#x4E8E;&#x63A7;&#x5236;&#x603B;&#x7EBF;&#x5916;&#x90E8;&#x786C;&#x4EF6;&#x7535;&#x8DEF;&#x7684;&#x6570;&#x636E;&#x5C31;&#x88AB;&#x79F0;&#x4E3A;&#x63A7;&#x5236;&#x5B57;. &#x5B9E;&#x9A8C;&#x4E09;&#x8BBE;&#x8BA1;&#x7684; GPIO &#x6A21;&#x5757;&#x5C31;&#x5305;&#x542B;&#x4E86; 3 &#x4E2A;&#x63A7;&#x5236;&#x5B57;, &#x4E00;&#x4E2A;&#x662F; oData &#x7528;&#x4E8E;&#x63A7;&#x5236; GPIO &#x7684;&#x5F15;&#x811A;&#x8F93;&#x51FA;&#x7684;&#x7535;&#x5E73;, &#x53E6;&#x4E00;&#x4E2A;&#x662F; iData &#x7528;&#x4E8E;&#x8868;&#x660E; GPIO &#x5F15;&#x811A;&#x8F93;&#x5165;&#x7684;&#x7535;&#x5E73;, &#x6700;&#x540E;&#x4E00;&#x4E2A;&#x662F; outEn &#x7528;&#x4E8E;&#x63A7;&#x5236; GPIO &#x7684;&#x8F93;&#x5165;&#x8F93;&#x51FA;&#x72B6;&#x6001;.</p>
<h2 id="&#x786C;&#x4EF6;&#x4EE3;&#x7801;">&#x786C;&#x4EF6;&#x4EE3;&#x7801;</h2>
<p>&#x6587;&#x4EF6; &quot;CortexM0_SoC/Task3/GPIO/rtl/GPIO.v&quot; &#x5C31;&#x662F;&#x4E0A;&#x56FE;&#x6240;&#x793A;&#x7684; 8 &#x4E2A; GPIO &#x63A5;&#x53E3;, &#x65E0;&#x9700;&#x81EA;&#x884C;&#x8BBE;&#x8BA1;.</p>
<p>&#x540C;&#x7406;, &#x5411; SoC &#x4E2D;&#x6DFB;&#x52A0; GPIO , &#x53C2;&#x8003;&#x5B9E;&#x9A8C;&#x4E8C;&#x6DFB;&#x52A0; RAMCODE &#x6B65;&#x9AA4;. &#x5728;&#x9876;&#x5C42;&#x6A21;&#x5757;&#x4E2D;&#x5DF2;&#x7ECF;&#x6DFB;&#x52A0;&#x597D; GPIO &#x603B;&#x7EBF;&#x63A5;&#x53E3;&#x4EE5;&#x53CA;&#x5BF9;&#x5E94;&#x7684;&#x786C;&#x4EF6;&#x4EE3;&#x7801;, &#x9700;&#x8981;&#x5B8C;&#x6210;&#x5C06;&#x6D41;&#x6C34;&#x706F;&#x603B;&#x7EBF;&#x63A5;&#x53E3;&#x63A5;&#x5165;&#x603B;&#x7EBF;&#x6269;&#x5C55;&#x6A21;&#x5757;&#x4E2D;&#x9884;&#x7559;&#x7684; P4 &#x63A5;&#x53E3;.</p>
<p>&#x7B2C;&#x4E00;&#x6B65;, &#x5728; &quot;AHBlite_Decoder.v&quot; &#x4E2D; GPIO(Port 4) &#x7AEF;&#x53E3;&#x53C2;&#x6570;&#x5C06;&#x5176;&#x4F7F;&#x80FD;.</p>
<pre><code class="lang-verilog"><span class="hljs-comment">/*GPIO enable parameter*/</span>
<span class="hljs-keyword">parameter</span> Port4_en = <span class="hljs-number">0</span>,
<span class="hljs-comment">/************************/</span>
</code></pre>
<p>&#x6539;&#x4E3A;</p>
<pre><code class="lang-verilog"><span class="hljs-comment">/* GPIO enable parameter*/</span>
<span class="hljs-keyword">parameter</span> Port4_en = <span class="hljs-number">1</span>,
<span class="hljs-comment">/************************/</span>
</code></pre>
<p>&#x7B2C;&#x4E8C;&#x6B65;, &#x672C;&#x6B21;&#x5B9E;&#x9A8C;&#x7ED9; GPIO &#x7684;&#x4E09;&#x4E2A;&#x63A7;&#x5236;&#x5B57;&#x5206;&#x914D;&#x5730;&#x5740;&#x7A7A;&#x95F4;&#x5982;&#x4E0B;: &#x8F93;&#x51FA;&#x6570;&#x636E;&#x5BC4;&#x5B58;&#x5668; oData &#x7684;&#x5730;&#x5740;&#x4E3A;0x40000020, &#x8F93;&#x5165;&#x6570;&#x636E;&#x5BC4;&#x5B58;&#x5668; iData &#x7684;&#x5730;&#x5740;&#x4E3A; 0x40000024 , &#x8F93;&#x51FA;&#x4F7F;&#x80FD;&#x5BC4;&#x5B58;&#x5668; outEn &#x7684;&#x5730;&#x5740;&#x4E3A; 0x40000028 . &#x56E0;&#x4E3A;&#x5BF9;&#x4E8E;&#x4E00;&#x6B21;&#x603B;&#x7EBF;&#x64CD;&#x4F5C;, &#x53EA;&#x8981;&#x5730;&#x5740;&#x603B;&#x7EBF;&#x7684;&#x9AD8; 28 &#x4F4D;&#x4E3A; 0x4000002 , &#x5219; Decoder &#x8BA4;&#x4E3A;&#x8FD9;&#x662F;&#x4E00;&#x6B21;&#x5BF9; GPIO &#x7684;&#x64CD;&#x4F5C;, &#x8FDB;&#x800C;&#x751F;&#x6210; GPIO &#x603B;&#x7EBF;&#x9009;&#x62E9;&#x4FE1;&#x53F7;. &#x5728;&#x8BD1;&#x7801;&#x90E8;&#x5206;&#x63D2;&#x5165; GPIO &#x7684;&#x8BD1;&#x7801;&#x5668;&#x4EE3;&#x7801;.</p>
<pre><code class="lang-verilog"><span class="hljs-comment">//0x40000028 OUT  ENABLE</span>
<span class="hljs-comment">//0X40000024 IN DATA</span>
<span class="hljs-comment">//0X40000020 OUT DATA</span>
<span class="hljs-comment">/*Insert GPIO decoder code there*/</span>
<span class="hljs-keyword">assign</span> P4_HSEL = <span class="hljs-number">1</span>&#x2019;b0;
<span class="hljs-comment">/***********************************/</span>
</code></pre>
<p>&#x6539;&#x4E3A;</p>
<pre><code class="lang-verilog"><span class="hljs-comment">//0x40000028 OUT  ENABLE</span>
<span class="hljs-comment">//0X40000024 IN DATA</span>
<span class="hljs-comment">//0X40000020 OUT DATA</span>
<span class="hljs-comment">/*Insert GPIO decoder code there*/</span>
<span class="hljs-keyword">assign</span> P4_HSEL = (HADDR[<span class="hljs-number">31</span>:<span class="hljs-number">4</span>] == <span class="hljs-number">28</span>&apos;h4000002) ? Port4_en : <span class="hljs-number">1&apos;d0</span>;
<span class="hljs-comment">/***********************************/</span>
</code></pre>
<p>&#x63A5;&#x4E0B;&#x6765;, &#x9700;&#x8981;&#x5728;&#x9876;&#x5C42;&#x6A21;&#x5757;&#x4E2D;&#x5C06; GPIO &#x603B;&#x7EBF;&#x63A5;&#x53E3;&#x4E0E;&#x6570;&#x636E;&#x5B58;&#x50A8;&#x5668;&#x603B;&#x7EBF;&#x63A5;&#x53E3;&#x5206;&#x522B;&#x4E0E;&#x603B;&#x7EBF;&#x6269;&#x5C55;&#x6A21;&#x5757;&#x7684; P1&#x3001;P4 &#x7AEF;&#x53E3;&#x8FDE;&#x63A5;, GPIO &#x5916;&#x8BBE;&#x548C;&#x6570;&#x636E;&#x5B58;&#x50A8;&#x5668;&#x4EE5;&#x53CA;&#x5B83;&#x4EEC;&#x7684;&#x603B;&#x7EBF;&#x63A5;&#x53E3;&#x90FD;&#x5DF2;&#x7ECF;&#x5728;&#x9876;&#x5C42;&#x6A21;&#x5757; &quot;CortexM0_SoC.v&quot; &#x4E2D;&#x4F8B;&#x5316;&#x5B8C;&#x6210;, &#x53EA;&#x9700;&#x8981;&#x5C06;&#x5176;&#x603B;&#x7EBF;&#x63A5;&#x53E3;&#x7684;&#x8FDE;&#x7EBF;&#x90E8;&#x5206;&#x8865;&#x5145;&#x5B8C;&#x6BD5;, &#x5B9E;&#x73B0;&#x6B63;&#x786E;&#x7684;&#x7AEF;&#x53E3;&#x8FDE;&#x63A5;.</p>
<h2 id="&#x6C47;&#x7F16;&#x4EE3;&#x7801;">&#x6C47;&#x7F16;&#x4EE3;&#x7801;</h2>
<p>&#x6309;&#x7167;&#x5B9E;&#x9A8C;&#x4E00;&#x6240;&#x8FF0;, &#x65B0;&#x5EFA; keil &#x5DE5;&#x7A0B;, &#x7F16;&#x5199;&#x6C47;&#x7F16;&#x7A0B;&#x5E8F;, &#x8BA9;&#x6D41;&#x6C34;&#x706F;&#x6D41;&#x8D77;&#x6765;.</p>
<p>&#x5728; &quot;/CortexM0_SoC/Task3/GPIO/keil/startup_CMSDK_CM0.s&quot; &#x6587;&#x4EF6;&#x4E2D;, &#x7A0B;&#x5E8F;&#x8FDB;&#x5165; GPIO &#x6BB5;&#x540E;, R2 &#x5B58;&#x50A8; GPIO &#x8F93;&#x51FA;&#x5BC4;&#x5B58;&#x5668;&#x7684;&#x5730;&#x5740;, R3 &#x5B58;&#x50A8; GPIO &#x8F93;&#x5165;&#x5BC4;&#x5B58;&#x5668;&#x7684;&#x5730;&#x5740;, R4 &#x5B58;&#x50A8;&#x8F93;&#x5165;/&#x8F93;&#x51FA;&#x6A21;&#x5F0F;&#x63A7;&#x5236;&#x5BC4;&#x5B58;&#x5668;&#x7684;&#x5730;&#x5740;, R1 &#x5B58;&#x50A8;&#x8BA1;&#x6570;&#x5668;&#x65F6;&#x95F4;.</p>
<p>&#x5982;&#x4F55;&#x7528;&#x6211;&#x4EEC;&#x8BBE;&#x8BA1;&#x7684; 8 &#x4E2A; GPIO &#x7AEF;&#x53E3;&#x5B9E;&#x73B0;&#x6D41;&#x6C34;&#x706F;&#x529F;&#x80FD;, &#x5176;&#x7A0B;&#x5E8F;&#x6D41;&#x7A0B;&#x5982;&#x4E0B;:</p>
<ol>
<li>&#x914D;&#x7F6E; GPIO &#x4E3A;&#x8F93;&#x51FA;&#x6A21;&#x5F0F;;</li>
<li>&#x5F80; oData &#x63A7;&#x5236;&#x5BC4;&#x5B58;&#x5668;&#x5199;&#x5165; 0x01 &#x70B9;&#x4EAE;&#x53F3;&#x8FB9;&#x7B2C;&#x4E00;&#x4E2A;&#x706F;&#x5E76;&#x4E14;&#x5EF6;&#x8FDF;&#x4E00;&#x5B9A;&#x65F6;&#x95F4;;</li>
<li>&#x5C06; 0x01 &#x5DE6;&#x79FB;&#x4E00;&#x4F4D;(&#x5373;0x02)&#x5199;&#x5165; oData &#x5BC4;&#x5B58;&#x5668;&#x4E2D;, &#x5E76;&#x4E14;&#x5EF6;&#x8FDF;&#x4E00;&#x5B9A;&#x65F6;&#x95F4;;</li>
<li>&#x91CD;&#x590D;&#x7B2C; 2 &#x3001;&#x7B2C; 3 &#x6B65;, &#x7B2C; 8 &#x4E2A;&#x706F;&#x70B9;&#x4EAE;&#x4E4B;&#x540E;, &#x518D;&#x6B21;&#x8DF3;&#x8F6C;&#x5230;&#x7B2C; 2 &#x6B65;.</li>
</ol>
<p>&#x9700;&#x8981;&#x6CE8;&#x610F;&#x7684;&#x662F;, &#x4E3A;&#x4E86;&#x65B9;&#x4FBF;&#x4EFF;&#x771F;&#x89C2;&#x5BDF;, &#x6211;&#x4EEC;&#x5C06;&#x5EF6;&#x8FDF;&#x7684;&#x95F4;&#x9694;&#x65F6;&#x95F4;&#x8BBE;&#x7F6E;&#x5F97;&#x975E;&#x5E38;&#x5C0F;, &#x5728;&#x63A5;&#x4E0B;&#x6765;&#x7684;&#x4E0A;&#x677F;&#x8C03;&#x8BD5;&#x65F6;, &#x9700;&#x8981;&#x91CD;&#x65B0;&#x4FEE;&#x6539; R0 &#x7684;&#x503C;, &#x4F7F;&#x6D41;&#x6C34;&#x706F;&#x6A21;&#x5F0F;&#x8F6C;&#x6362;&#x65F6;&#x95F4;&#x4FDD;&#x6301;&#x5728; 1s &#x5DE6;&#x53F3;.</p>
<p>&#x5728;&#x6C47;&#x7F16;&#x6587;&#x4EF6;&#x4E2D;&#x8865;&#x5145;&#x4EE3;&#x7801;&#x6BB5;, &#x5B9E;&#x73B0;&#x5F80;&#x5DE6;&#x6D41;&#x7684;&#x6D41;&#x6C34;&#x706F;&#x529F;&#x80FD;, &#x5E76;&#x4E14;&#x5229;&#x7528; R1 &#x8BA1;&#x6570;&#x81F3; 16 &#x540E;&#x8FD4;&#x56DE;&#x5B9E;&#x73B0;delay&#x529F;&#x80FD;.</p>
<pre><code>; Finish function code 

;;;;;;;;;;;;;;;;;;;;;;
</code></pre><p>&#x6539;&#x4E3A;</p>
<pre><code class="lang-ARM"><span class="hljs-comment">; Finish function code </span>
<span class="hljs-symbol">GPIO</span>            <span class="hljs-keyword">LDR </span><span class="hljs-built_in">R6</span>, <span class="hljs-number">=0x00</span>         <span class="hljs-comment">;GPIO INPUT ENABLE VALUE</span>
                <span class="hljs-keyword">STR </span><span class="hljs-built_in">R6</span>, [<span class="hljs-built_in">R4</span>]          <span class="hljs-comment">;Set input ENABLE</span>
                <span class="hljs-keyword">LDR </span><span class="hljs-built_in">R5</span>, [<span class="hljs-built_in">R3</span>]          <span class="hljs-comment">;read GPIO value</span>

                <span class="hljs-keyword">LDR </span><span class="hljs-built_in">R6</span>, <span class="hljs-number">=0x01</span>         <span class="hljs-comment">;GPIO OUTPUT ENABLE VALUE</span>
                <span class="hljs-keyword">STR </span><span class="hljs-built_in">R6</span>, [<span class="hljs-built_in">R4</span>]          <span class="hljs-comment">;Set OUTPUT ENABLE</span>

                <span class="hljs-keyword">LDR </span><span class="hljs-built_in">R6</span>, <span class="hljs-number">=0X01</span>         <span class="hljs-comment">;GPIO_0 Set value</span>
                <span class="hljs-keyword">STR </span><span class="hljs-built_in">R6</span>, [<span class="hljs-built_in">R2</span>]          <span class="hljs-comment">;store</span>
                <span class="hljs-keyword">MOVS </span><span class="hljs-built_in">R1</span>, <span class="hljs-number">#1</span>           <span class="hljs-comment">;Interval cnt initial</span>
                <span class="hljs-keyword">BL </span>delay
                <span class="hljs-keyword">LDR </span><span class="hljs-built_in">R6</span>, <span class="hljs-number">=0X02</span>         <span class="hljs-comment">;GPIO_1 Set value</span>
                <span class="hljs-keyword">STR </span><span class="hljs-built_in">R6</span>, [<span class="hljs-built_in">R2</span>]          <span class="hljs-comment">;store</span>
                <span class="hljs-keyword">MOVS </span><span class="hljs-built_in">R1</span>, <span class="hljs-number">#1</span>           <span class="hljs-comment">;Interval cnt initial</span>
                <span class="hljs-keyword">BL </span>delay
                <span class="hljs-keyword">LDR </span><span class="hljs-built_in">R6</span>, <span class="hljs-number">=0X04</span>         <span class="hljs-comment">;GPIO_2 Set value</span>
                <span class="hljs-keyword">STR </span><span class="hljs-built_in">R6</span>, [<span class="hljs-built_in">R2</span>]           <span class="hljs-comment">;store</span>
                <span class="hljs-keyword">MOVS </span><span class="hljs-built_in">R1</span>, <span class="hljs-number">#1</span>            <span class="hljs-comment">;Interval cnt initial</span>
                <span class="hljs-keyword">BL </span>delay
                <span class="hljs-keyword">LDR </span><span class="hljs-built_in">R6</span>, <span class="hljs-number">=0X08</span>          <span class="hljs-comment">;GPIO_3 Set value</span>
                <span class="hljs-keyword">STR </span><span class="hljs-built_in">R6</span>, [<span class="hljs-built_in">R2</span>]           <span class="hljs-comment">;store</span>
                <span class="hljs-keyword">MOVS </span><span class="hljs-built_in">R1</span>, <span class="hljs-number">#1</span>            <span class="hljs-comment">;Interval cnt initial</span>
                <span class="hljs-keyword">BL </span>delay
                <span class="hljs-keyword">LDR </span><span class="hljs-built_in">R6</span>, <span class="hljs-number">=0X10</span>          <span class="hljs-comment">;GPIO_4 Set value</span>
                <span class="hljs-keyword">STR </span><span class="hljs-built_in">R6</span>, [<span class="hljs-built_in">R2</span>]           <span class="hljs-comment">;store</span>
                <span class="hljs-keyword">MOVS </span><span class="hljs-built_in">R1</span>, <span class="hljs-number">#1</span>            <span class="hljs-comment">;Interval cnt initial</span>
                <span class="hljs-keyword">BL </span>delay
                <span class="hljs-keyword">LDR </span><span class="hljs-built_in">R6</span>, <span class="hljs-number">=0X20</span>          <span class="hljs-comment">;GPIO_5 Set value</span>
                <span class="hljs-keyword">STR </span><span class="hljs-built_in">R6</span>, [<span class="hljs-built_in">R2</span>]           <span class="hljs-comment">;store</span>
                <span class="hljs-keyword">MOVS </span><span class="hljs-built_in">R1</span>, <span class="hljs-number">#1</span>            <span class="hljs-comment">;Interval cnt initial</span>
                <span class="hljs-keyword">BL </span>delay
                <span class="hljs-keyword">LDR </span><span class="hljs-built_in">R6</span>, <span class="hljs-number">=0X40</span>          <span class="hljs-comment">;GPIO_6 Set value</span>
                <span class="hljs-keyword">STR </span><span class="hljs-built_in">R6</span>, [<span class="hljs-built_in">R2</span>]           <span class="hljs-comment">;store</span>
                <span class="hljs-keyword">MOVS </span><span class="hljs-built_in">R1</span>, <span class="hljs-number">#1</span>            <span class="hljs-comment">;Interval cnt initial</span>
                <span class="hljs-keyword">BL </span>delay
                <span class="hljs-keyword">LDR </span><span class="hljs-built_in">R6</span>, <span class="hljs-number">=0X80</span>          <span class="hljs-comment">;GPIO_7 Set value</span>
                <span class="hljs-keyword">STR </span><span class="hljs-built_in">R6</span>, [<span class="hljs-built_in">R2</span>]           <span class="hljs-comment">;store</span>
                <span class="hljs-keyword">MOVS </span><span class="hljs-built_in">R1</span>, <span class="hljs-number">#1</span>            <span class="hljs-comment">;Interval cnt initial</span>
                <span class="hljs-keyword">BL </span>delay
                <span class="hljs-keyword">B </span>GPIO

<span class="hljs-symbol">delay</span>           <span class="hljs-keyword">ADDS </span><span class="hljs-built_in">R1</span>,<span class="hljs-built_in">R1</span>,<span class="hljs-number">#1</span>
                <span class="hljs-keyword">LDR </span><span class="hljs-built_in">R0</span>,<span class="hljs-number">=0X10</span>
                <span class="hljs-keyword">CMP </span><span class="hljs-built_in">R0</span>,<span class="hljs-built_in">R1</span>
                <span class="hljs-keyword">BNE </span>delay
                <span class="hljs-keyword">BX </span> <span class="hljs-built_in">LR</span>
<span class="hljs-comment">;;;;;;;;;;;;;;;;;;;;;;</span>
</code></pre>
<p>&#x4ECE;&#x4E0A;&#x9762;&#x7684;&#x793A;&#x4F8B;&#x4EE3;&#x7801;&#x4E2D;, &#x6211;&#x4EEC;&#x5728;&#x4EE3;&#x7801;&#x7684;&#x4E00;&#x5F00;&#x59CB;&#x8FD8;&#x5C06; GPIO &#x914D;&#x7F6E;&#x6210;&#x8F93;&#x5165;&#x6A21;&#x5F0F;, &#x4EE5;&#x68C0;&#x9A8C; GPIO &#x7684;&#x8F93;&#x5165;&#x529F;&#x80FD;, &#x8FD9;&#x4E00;&#x529F;&#x80FD;&#x53EF;&#x4EE5;&#x5728; FPGA&#x5F00;&#x53D1;&#x677F;&#x4E2D;&#x9A8C;&#x8BC1;&#x4E2D;&#x5F97;&#x5230;&#x68C0;&#x9A8C;.</p>
<h2 id="&#x7CFB;&#x7EDF;&#x4EFF;&#x771F;&#x548C;&#x8C03;&#x8BD5;">&#x7CFB;&#x7EDF;&#x4EFF;&#x771F;&#x548C;&#x8C03;&#x8BD5;</h2>
<h3 id="modelsim-&#x4EFF;&#x771F;">ModelSim &#x4EFF;&#x771F;</h3>
<p>&#x6309;&#x7167;&#x5B9E;&#x9A8C;&#x4E00;&#x6240;&#x8FF0;, &#x65B0;&#x5EFA; modelsim &#x5DE5;&#x7A0B;, &#x5C06;&#x4E4B;&#x524D;&#x7F16;&#x5199;&#x7684; verilog &#x6587;&#x4EF6;&#x6DFB;&#x52A0;&#x8FDB;&#x5DE5;&#x7A0B;, &#x7F16;&#x8BD1;&#x5E76;&#x5F00;&#x59CB;&#x4EFF;&#x771F;, &#x89C2;&#x5BDF;&#x6CE2;&#x5F62;, &#x53EF;&#x4EE5;&#x770B;&#x5230;&#x6BCF;&#x4E2A;&#x4E00;&#x6BB5;&#x65F6;&#x95F4;, GPIO &#x7684;&#x8F93;&#x51FA;&#x90FD;&#x4F1A;&#x5DE6;&#x79FB;&#x4E00;&#x4F4D;, &#x5C06;&#x8FD9;&#x4E9B;&#x63A5;&#x53E3;&#x63A5;&#x5230;&#x5F00;&#x53D1;&#x677F;&#x7684; LED &#x706F;&#x4E0A;, &#x5C31;&#x6784;&#x6210;&#x4E86;&#x5DE6;&#x5411;&#x6D41;&#x6C34;&#x706F;.</p>
<h3 id="&#x786C;&#x4EF6;&#x8C03;&#x8BD5;">&#x786C;&#x4EF6;&#x8C03;&#x8BD5;</h3>
<p>&#x7531;&#x4E8E; Keil &#x8C03;&#x8BD5;&#x662F;&#x8FDB;&#x884C;&#x7684;&#x5355;&#x6B65;&#x8C03;&#x8BD5;, &#x56E0;&#x6B64;&#x6682;&#x65F6;&#x4E0D;&#x5FC5;&#x5BF9; R1 &#x7684;&#x503C;&#x8FDB;&#x884C;&#x8C03;&#x6574;, &#x5F53;&#x524D; R1 &#x7684;&#x503C;&#x51B3;&#x5B9A;&#x4E86;&#x6BCF; 30 &#x6B65;&#x5DE6;&#x53F3;&#x6D41;&#x6C34;&#x706F;&#x6A21;&#x5F0F;&#x6539;&#x53D8;&#x4E00;&#x6B21;.</p>
<p>&#x5C06;&#x65B0;&#x7F16;&#x5199;&#x7684; verilog &#x6587;&#x4EF6;&#x6DFB;&#x52A0;&#x8FDB; vivado &#x5DE5;&#x7A0B;&#x4E2D;, &#x5C06; GPIO[0:6] &#x5206;&#x914D;&#x5230;&#x5F00;&#x53D1;&#x7684; LED0-LED6 &#x4E0A;, &#x540C;&#x65F6;&#x4E3A;&#x4E86;&#x9A8C;&#x8BC1;&#x8F93;&#x5165;&#x529F;&#x80FD;&#x5C06;GPIO7 &#x7EA6;&#x675F;&#x5230;&#x5F00;&#x5173; SW1 &#x4E0A;, &#x7EFC;&#x5408;&#x5E03;&#x5C40;&#x5E03;&#x7EBF;&#x540E;&#x751F;&#x6210;&#x6BD4;&#x7279;&#x6D41;&#x6587;&#x4EF6;&#x5E76;&#x4E0B;&#x8F7D;&#x8FDB; FPGA &#x4E2D;.</p>
<p>&#x6309;&#x7167;&#x5B9E;&#x9A8C;&#x4E8C;&#x8BB2;&#x8FF0;&#x7684;&#x65B9;&#x6CD5;&#x8FDE;&#x63A5;&#x8C03;&#x8BD5;&#x5668;&#x4E0E; PC , &#x6253;&#x5F00; Keil &#x8FDB;&#x884C;&#x8C03;&#x8BD5;, &#x8C03;&#x8BD5;&#x7ED3;&#x679C;&#x5982;&#x4E0B;&#x56FE;&#x6240;&#x793A;. &#x5728;&#x8FDB;&#x884C;&#x8C03;&#x8BD5;&#x4E4B;&#x524D;, &#x5C06;&#x5F00;&#x53D1;&#x677F;&#x7684;&#x62E8;&#x7801;&#x5F00;&#x5173; SW1 &#x5F80;&#x4E0A;&#x62E8;, &#x4F7F;&#x5176;&#x8FDE;&#x63A5;&#x5230;&#x7535;&#x6E90; VDD &#x4E0A;. &#x5728;&#x5355;&#x6B65;&#x8C03;&#x8BD5;&#x5230;&#x4E0B;&#x56FE;&#x6240;&#x793A;&#x7684; 38 &#x884C;&#x4EE3;&#x7801;, &#x8BFB;&#x53D6; GPIO &#x8F93;&#x5165;&#x7684;&#x503C;&#x65F6;, &#x6211;&#x4EEC;&#x53EF;&#x4EE5;&#x770B;&#x5230;&#x8BFB;&#x53D6;&#x5230;&#x7684;&#x503C;&#x5B58;&#x50A8;&#x5230; R5 &#x5BC4;&#x5B58;&#x5668;&#x4E2D;, &#x5176;&#x503C;&#x662F; 0x00000080, &#x8868;&#x793A; GPIO7 &#x8F93;&#x5165;&#x7684;&#x503C;&#x4E3A; 1 , &#x7B26;&#x5408;&#x5B9E;&#x9A8C;&#x73B0;&#x8C61;. &#x63A5;&#x4E0B;&#x6765;&#x7EE7;&#x7EED;&#x5355;&#x6B65;&#x8C03;&#x8BD5;&#x5C31;&#x80FD;&#x770B;&#x5230; LED0 &#x81F3; LED6 &#x4F9D;&#x6B21;&#x70B9;&#x4EAE;.</p>
<p><div align="center"><img src="../img/lab3/15.png" alt="01" style="zoom:100%;"></div></p>
<footer class="page-footer-ex"> <span class="page-footer-ex-copyright"> By UESTC Intelligent Chip and System Design Lab. &#x91C7;&#x7528;<a href="https://creativecommons.org/licenses/by-nc-sa/3.0/cn/" target="_blank">&#x77E5;&#x8BC6;&#x5171;&#x4EAB; &#x7F72;&#x540D;-&#x975E;&#x5546;&#x4E1A;&#x6027;&#x4F7F;&#x7528;-&#x76F8;&#x540C;&#x65B9;&#x5F0F;&#x5171;&#x4EAB; 3.0 &#x4E2D;&#x56FD;&#x5927;&#x9646; &#x8BB8;&#x53EF;&#x534F;&#x8BAE;</a>&#x53D1;&#x5E03; </span> &#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0; <span class="page-footer-ex-footer-update"> &#x6B64;&#x9875;&#x9762;&#x4FEE;&#x8BA2;&#x4E8E; 2022-04-29 21:55:31 </span> </footer>
                                
                                </section>
                            
    </div>
    <div class="search-results">
        <div class="has-results">
            
            <h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
            <ul class="search-results-list"></ul>
            
        </div>
        <div class="no-results">
            
            <h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
            
        </div>
    </div>
</div>

                        </div>
                    </div>
                
            </div>

            
                
                <a href="data_storage.html" class="navigation navigation-prev " aria-label="Previous page: 数据存储器">
                    <i class="fa fa-angle-left"></i>
                </a>
                
                
                <a href="WaterLight.html" class="navigation navigation-next " aria-label="Next page: 硬件流水灯">
                    <i class="fa fa-angle-right"></i>
                </a>
                
            
        
    </div>

    <script>
        var gitbook = gitbook || [];
        gitbook.push(function() {
            gitbook.page.hasChanged({"page":{"title":"GPIO外设实现流水灯","level":"1.5.2","depth":2,"next":{"title":"硬件流水灯","level":"1.5.3","depth":2,"path":"lab3/WaterLight.md","ref":"lab3/WaterLight.md","articles":[]},"previous":{"title":"数据存储器","level":"1.5.1","depth":2,"path":"lab3/data_storage.md","ref":"lab3/data_storage.md","articles":[]},"dir":"ltr"},"config":{"plugins":["intopic-toc","callouts","page-footer-ex","-livereload","theme-comscore","-sharing"],"styles":{"website":"styles/styles.css"},"pluginsConfig":{"callouts":{"important":{"alert":"danger","picto":"fa-bullhorn"},"danger":{"alert":"danger","picto":"fa-exclamation-circle"},"question":{"alert":"info","picto":"fa-question-circle"},"hint":{"alert":"success","picto":"fa-lightbulb-o"},"showTypeInHeader":false,"must":{"alert":"warning","picto":"fa-edit"},"flag":{"alert":"success","picto":"fa-flag"},"info":{"alert":"info","picto":"fa-info-circle"},"note":{"alert":"info","picto":"fa-edit"},"fread":{"alert":"info","picto":"fa-comment"}},"intopic-toc":{"isCollapsed":true,"isScrollspyActive":true,"label":"导航","maxDepth":6,"mode":"nested","selector":".markdown-section h1, .markdown-section h2, .markdown-section h3, .markdown-section h4","visible":true},"page-footer-ex":{"copyright":"By UESTC Intelligent Chip and System Design Lab. 采用[知识共享 署名-非商业性使用-相同方式共享 3.0 中国大陆 许可协议](https://creativecommons.org/licenses/by-nc-sa/3.0/cn/)发布","markdown":true,"update_format":"YYYY-MM-DD HH:mm:ss","update_label":"此页面修订于"},"search":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"fontsettings":{"theme":"white","family":"sans","size":2},"highlight":{},"theme-comscore":{},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"theme":"default","pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"variables":{},"title":"WQ GitBook","gitbook":"*"},"file":{"path":"lab3/GPIO.md","mtime":"2022-04-29T13:55:31.043Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2023-03-16T07:13:54.762Z"},"basePath":"..","book":{"language":""}});
        });
    </script>
</div>

        
    <script src="../gitbook/gitbook.js"></script>
    <script src="../gitbook/theme.js"></script>
    
        
        <script src="../gitbook/gitbook-plugin-intopic-toc/anchor.min.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-intopic-toc/gumshoe.polyfills.min.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-intopic-toc/plugin.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-search/search-engine.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-search/search.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-lunr/lunr.min.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-lunr/search-lunr.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-theme-comscore/test.js"></script>
        
    

    </body>
</html>

